﻿using Mengsk.ProxyDelivery.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Print.Domain.PrintDataFormatters
{
    class PrintDataFormatterOrder_Weight : PrintDataFormatter
    {
        public override PrintTemplateItemTypes AcceptType
        {
            get { return PrintTemplateItemTypes.ORDER_WEIGHT; }
        }

        public override object Format(PrintTemplate template, PrintTemplateItem item, Order order)
        {
            if (order.Weight <= 0)
            {
                return "";
            }

            if (order.OrderGoodss == null || order.OrderGoodss.Count < 1)
            {
                return "0.6";
            }

            if (order.OrderGoodss.Any(obj => obj.Weight <= 0))
            {
                return "";
            }

            return order.Weight.ToString("F2") + "KG";
        }
    }
}
